<?php foreach ($elements as $element): ?>
    <li>
        <span class="file">
            <?php if($sf_user->hasCredential('Ver elemento')): ?>
                <?php echo jq_link_to_remote(
                        $element,
                        array(
                            'update' => 'main',
                            'url'    => url_for('element_show',$element),
                            'before' => 'clearView();showLoaderMain();',
                            'complete' => 'hideLoader();',
                            'script' => true
                        )) ?>
            <?php else: ?>
                <?php echo $element ?>
            <?php endif; ?>
            <a id="<?php echo "element".$element->getId()."_menu_options"?>" tabindex="0" href="#menu_element_options"
                class="content_menu ui-button ui-widget ui-state-default ui-corner-all ui-button-icons-only"
                aria-disabled="false" title="Opciones">
                <span class="ui-button-icon-primary ui-icon ui-icon-circle-plus"></span>
                <span class="ui-button-text">Opciones</span>
                <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span>
            </a>
            <div id="element_menu_options" class="ui-helper-hidden-accessible">
                <ul>
                    <?php if($sf_user->hasCredential('Ver elemento')): ?>
                        <li>
                            <?php echo jq_link_to_remote(
                                    '<span class="menu-bullet ui-icon ui-icon-bullet"></span> Ver',
                                    array(
                                        'update' => 'main',
                                        'url'    => url_for('element_show',$element),
                                        'before' => 'clearView();showLoaderMain();',
                                        'complete' => 'hideLoader();',
                                        'script' => true
                                    )) ?>
                        </li>
                    <?php endif; ?>
                    <?php if($sf_user->hasCredential('Editar elemento')): ?>
                        <?php if ($element->getType()->getType() == 'Form' && $element->getSection()->getType()->getType() == 'Register'): ?>
                            <?php if($sf_user->hasCredential('Editar formulario de registro')):?>
                                <li>
                                    <?php echo jq_link_to_remote(
                                            '<span class="menu-bullet ui-icon ui-icon-bullet"></span> Editar',
                                            array(
                                                'update' => 'main',
                                                'url'    => url_for('element_edit',$element),
                                                'before' => 'clearView();showLoaderMain();',
                                                'complete' => 'hideLoader();',
                                                'script' => true
                                            )) ?>
                                </li>
                            <?php endif; ?>
                        <?php else: ?>
                            <li>
                                <?php echo jq_link_to_remote(
                                        '<span class="menu-bullet ui-icon ui-icon-bullet"></span> Editar',
                                        array(
                                            'update' => 'main',
                                            'url'    => url_for('element_edit',$element),
                                            'before' => 'clearView();showLoaderMain();',
                                            'complete' => 'hideLoader();',
                                            'script' => true
                                        )) ?>
                            </li>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php if($sf_user->hasCredential('Exportar registros') 
                            && $element->getType()->getType() == 'Form'
                            && $element->getForm()->getRegisters()->count()): ?>
                        <li>
                            <a id="export_button" href="<?php echo url_for('element_export_form_registers', $element)?>"
                               target="_blank" title="Exportar a Excel">
                                <span class="menu-bullet ui-icon ui-icon-bullet"></span> Exportar registros
                            </a>
                        </li>
                    <?php endif; ?>
                </ul>
            </div>
        </span>
    </li>
<?php endforeach; ?>

